package com.firexxx.common.errors;

import lombok.Getter;

/**
 * Created by mmxu6 on 2019-09-01.
 */
@Getter
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = 4770994130964274474L;

    private BusinessError error;
    private String detail;

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(Throwable throwable) {
        super(throwable);
    }

    public BusinessException(String message, Throwable throwable) {
        super(message, throwable);
    }

    public BusinessException(BusinessError error) {
        super(error.getLoggerMessage());
        this.error = error;
    }

    public BusinessException(BusinessError error, String detail) {
        super(error.getLoggerMessage() + ", " + detail);
        this.error = error;
        this.detail = detail;
    }

    public BusinessException(BusinessError error, String detail, Throwable throwable) {
        super(error.getLoggerMessage() + ", " + detail, throwable);
        this.error = error;
        this.detail = detail;
    }
}
